/*
 *  Blazon: A user datagram protocol re-braodcasting daemon.
 *  event.h: Header file for event.c
 *
 *  Copyright 2012 Blazon development team
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 2 of the License, or
 *  (at your option) any later version.

 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef INCLUDED_event_h
#define INCLUDED_event_h

typedef void EVH(void *);

struct ev_entry
{
	dlink_node node;
	EVH *func;
	void *arg;
	char *name;
	time_t frequency;
	time_t when;
	time_t next;
	void *data;
	void *comm_ptr;
};


struct ev_entry *event_add(const char *name, EVH * func, void *arg, time_t when);
struct ev_entry *event_addonce(const char *name, EVH * func, void *arg, time_t when);
struct ev_entry *event_addish(const char *name, EVH * func, void *arg, time_t delta_ish);
void event_run(void);
void event_init(void);
void event_delete(struct ev_entry *);
void event_find_delete(EVH * func, void *);
void event_update(struct ev_entry *, time_t freq);
void set_back_events(time_t);
void dump_events(void (*func) (char *, void *), void *ptr);
void clear_all_events(void);
void run_event(struct ev_entry *);
time_t event_next(void);

#endif /* INCLUDED_event_h */
